#include <iostream>

using std::cout;
using std::endl;

class Base
{
public:

    //当基类中定义了有参构造函数时，系统就不会再提供默认构造函数
    Base()
    //: _base(0)
    {   cout << "Base()" << endl;}

    Base(long base)
    : _base(base)
    {   
        cout << "Base(long)" << endl;
    }
    
    void print() const
    {   cout << "Base::_base:" << _base << endl;    }
private:
    long _base;
};

class Derived
: public Base
{
//1. 派生类没有显式定义自己的构造函数，而基类有显式定义自己的构造函数
//则基类必须要提供默认构造函数;否则编译无法通过
public:
    //Derived(){}
    Derived()
    : Base() //即使不写，也会自动调用基类默认构造函数
    {   cout << "Derived()" << endl;}

private:
    long _derived;
};

int main()
{
    Derived d1;

    return 0;
}

